package com.lz.ovuola.web.filter;

import java.util.ArrayList;
import java.util.List;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.CharacterEncodingFilter;

@Configuration
public class CharacterEncodingFilterBean {
	private final String url = "/*";

	@Bean
	public FilterRegistrationBean myFilterRegistration() {
		FilterRegistrationBean registrationBean = new FilterRegistrationBean();
		CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
		characterEncodingFilter.setEncoding("UTF-8");
		registrationBean.setFilter(characterEncodingFilter);
		List<String> urls = new ArrayList<String>(1) {
			private static final long serialVersionUID = 1L;
			{
				add(url);
			}
		};
		registrationBean.setUrlPatterns(urls);
		return registrationBean;
	}
}
